-
Notifications
You must be signed in to change notification settings - Fork 1.2k
*: add slow log control variables (tidb_slow_log_rules, tidb_slow_log_max_per_sec) and hint write_slow_log #21009
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
system-variables.md
Outdated
| - 默认值:`0` | ||
| - 类型:整数型 | ||
| - 范围:`[0, 1000000]` | ||
| - 控制每秒打印慢日志每秒的次数上限,默认值 0。当该变量值为 0 时,则表示不限制每秒打印的慢日志数量。当该变量值大于 0 时,TiDB 会限制每秒打印的慢日志数量不超过该值,超过部分的慢日志将被丢弃,不会写入慢日志文件。该变量常与 [`tidb_slow_log_rules`](#tidb_slow_log_rules) 结合使用,以防止在高负载情况下产生过多的慢日志。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
其中峰值可能超过配值(峰值 = 2*tidb_slow_log_max_per_sec),平均打印速率仍然受 tidb_slow_log_max_per_sec 限制。这个内容是否需要说明?
3552306 to
a405cf8
Compare
| ### 相关系统变量 | ||
|
|
||
| * [tidb_slow_log_threshold](/system-variables.md#tidb_slow_log_threshold):设置慢日志的阈值,执行时间超过阈值的 SQL 语句将被记录到慢日志中。默认值是 300 ms。 | ||
| * [tidb_slow_log_rules](/system-variables.md#tidb_slow_log_rules):用于定义慢日志的触发规则,支持多维度指标组合条件,实现更加灵活和精细化的日志记录控制。此变量在新版本中引入,逐步替代传统的单一阈值控制方式,即替代 `tidb_slow_log_threshold` 的使用。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不知道要不要 明确 是哪一个版本
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
感觉要写一下,但不确定写 v9.0.0 还是 v9.0-beta3 @lilin90 知道吗?
identify-slow-queries.md
Outdated
| * [tidb_slow_log_max_per_sec](/system-variables.md#tidb_slow_log_max_per_sec):设置控制每秒打印慢日志的上限,默认值为 0。 | ||
| * 当值为 0,其表示不限制每秒打印的慢日志数量。 | ||
| * 当值大于 0 时,TiDB 每秒最多打印指定数量的慢日志,超过部分将被丢弃,不会写入慢日志文件。 | ||
| * 建议在启用了 tidb_slow_log_rules 后配置该变量,以防规则触发频繁打印慢日志。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
要不要再补充下,可能影响系统查询性能。
| | └─IndexScan_16 cop 31281.857819905217 table:t, index:idx(a), range:[-inf,50000), keep order:false 25007 time:11ms, loops:25 N/A N/A | | ||
| +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | ||
| ``` | ||
| ```sql |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥要加缩进啊?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
因为这个 sql 是上面 216 行的示例,所以我给它做了缩进。
system-variables.md
Outdated
| - 默认值:`0` | ||
| - 类型:整数型 | ||
| - 范围:`[0, 1000000]` | ||
| - 控制每秒打印慢日志每秒的次数上限,默认值 0。当该变量值为 0 时,则表示不限制每秒打印的慢日志数量。当该变量值大于 0 时,TiDB 会限制每秒打印的慢日志数量不超过该值,超过部分的慢日志将被丢弃,不会写入慢日志文件。该变量常与 [`tidb_slow_log_rules`](#tidb_slow_log_rules) 结合使用,以防止在高负载情况下产生过多的慢日志。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
控制每个 TiDB 节点每秒,限定下是按照单节点算?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是按单节点算的。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
a405cf8 to
437be1b
Compare
First-time contributors' checklist
What is changed, added or deleted? (Required)
pingcap/tidb#64010
Add slow log control variables (tidb_slow_log_rules, tidb_slow_log_max_per_sec) and hint write_slow_log
Which TiDB version(s) do your changes apply to? (Required)
Tips for choosing the affected version(s):
By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.
For details, see tips for choosing the affected versions (in Chinese).
What is the related PR or file link(s)?
Do your changes match any of the following descriptions?